package com.binhthuan.catechist.client.grid;

import com.binhthuan.catechist.client.ECApplication;
import com.binhthuan.catechist.client.data.GradeDS;
import com.binhthuan.catechist.client.data.TrainerDS;
import com.binhthuan.catechist.shared.constant.Parameter;
import com.smartgwt.client.widgets.grid.ListGridField;

public class GradeGrid extends AbstractGrid {

    public GradeGrid() {
    }

    public GradeGrid(GradeDS dataSource) {
        super(dataSource);
        setWrapCells(true);

        ListGridField idField = new ListGridField(Parameter.ID);
        idField.setHidden(true);
        idField.setCanHide(false);

        ListGridField nameField = new ListGridField(Parameter.NAME);
        nameField.setTitle(ECApplication.getConstants().grade());

        ListGridField leaderField = new ListGridField(Parameter.LEADER);
        leaderField.setTitle(ECApplication.getConstants().gradeLeader());
        leaderField.setOptionDataSource(TrainerDS.getInstance());
        leaderField.setDisplayField(Parameter.FULL_NAME);
        leaderField.setValueField(Parameter.ID);

        setSortField(Parameter.NAME);
        setFields(idField, nameField, leaderField);
    }
}
